<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <title>个人贷款</title>
    <link rel="stylesheet" href="./css/idangerous.swiper.css">
    <link rel="stylesheet" type="text/css" href="./css/common.css">
    <style>
        /* Demo Syles */
        body {
            margin: 0;
            font-family: Arial, Helvetica, sans-serif;
            line-height: 1.5;
        }

        .device {
            width: 640px;
            height: 300px;
            padding: 30px 40px;
            border-radius: 20px;
            background: #111;
            border: 3px solid white;
            margin: 5px auto;
            position: relative;
            box-shadow: 0px 0px 5px #000;
        }

/*        .device .arrow-left {
            background: url(img/arrows.png) no-repeat left top;
            position: absolute;
            left: 10px;
            top: 50%;
            margin-top: -15px;
            width: 17px;
            height: 30px;
        }

        .device .arrow-right {
            background: url(img/arrows.png) no-repeat left bottom;
            position: absolute;
            right: 10px;
            top: 50%;
            margin-top: -15px;
            width: 17px;
            height: 30px;
        }*/

        .swiper-container {
            width: 100%;
        }

        .content-slide {
            padding: 20px;
            color: #fff;
        }

        .title {
            font-size: 25px;
            margin-bottom: 10px;
        }

        .pagination {
            position: absolute;
            left: 0;
            text-align: center;
            bottom: 5px;
            width: 100%;
            z-index: 9999;
        }

        .swiper-pagination-switch {
            display: inline-block;
            width: 10px;
            height: 10px;
            border-radius: 10px;
            background: #999;
            box-shadow: 0px 1px 2px #555 inset;
            margin: 0 3px;
            cursor: pointer;
        }

        .swiper-active-switch {
            background: #fff;
        }

        .swiperBox {
            width: 100%;
            position: relative;
        }

        img {
            width: 100%;
        }

        .centerGray {
            height: 5px;
            border-top: #eeeeee;
            border-bottom: #eeeeee;
            background: #f3f5f7;
            width: 100%;
            box-shadow: inset 0px 0px 4px 1px #e2e2e2;
        }

        .type {
            overflow: hidden;
            padding: 10px 0px;
        }

        .type div {
            float: left;
            width: 33.3%;
            text-align: center;
        }

        .type img {
            width: 50px;
        }

        .type p {
            margin: 0px;
            padding: 0px;
        }

        .bank {
            overflow: hidden;
            padding: 10px 0px;
            background: white;
            padding-bottom: 42px;
        }

        .bank img {
            float: left;
            width: 75px;
            margin-top: 12px;
            margin-left: 5px;
        }

        .bank div {
            float: left;
            width: 45%;
            margin-top: 12px;
            margin-left: 3%;
        }

        .bank p {
            line-height: 20px;
            margin: 0px;
            padding: 0px;
            font-size: 12px;
        }

        .bank .detail {
            width: 70px;
            float: right;
            margin-left: 0px;
            margin-right: 15px;
            margin-top: 27px;
            border: 1px solid #dcdcdc;
            text-align: center;
            box-sizing: border-box;
            line-height: 30px;
            border-radius: 5px;
            color: red;
            font-size: 12px;
        }

        .say {
            position: fixed;
            left: 0px;
            top: 0px;
            width: 100%;
            z-index: 999;
        }

        .say img {
            width: 18px;
            float: left;
            margin-right: 12px;
        }

        .say p {
            float: left;
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
    <div class="say">
        <marquee>
            <p style="font-size: 12px;color: red;">
                <img src="./images/la.gif">
                特别声明：星丝路从未授权委托任何机构或个人开展任何有关星丝路的有偿信息服务。
                星丝路在提供信息服务过程中，不会向用户收取任何名义的费用。
            </p>
        </marquee>
    </div>
    <div class="swiperBox">
        <!--<a class="arrow-left" href="#"></a>
        <a class="arrow-right" href="#"></a>-->
        <div class="swiper-container">
            <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <img src="./images/bg1.jpg" alt="">
                </div>
                <div class="swiper-slide">
                    <img src="./images/bg2.jpg" alt="">
                </div>
                <div class="swiper-slide">
                    <img src="./images/bg3.jpg" alt="">
                </div>
            </div>
        </div>
        <div class="pagination"></div>
    </div>
    <div class="centerGray"></div>
    <div class="type">
    </div>
    <div class="centerGray"></div>
    <div class="bank">
    </div>
    <footer class="footer" style="height: 40px!important;">
        <a href="../../login.html" class="ripple active"  style="font-size: 14px;"><span class="icon f1"  style="width: 17px;height: 17px;"></span>个人贷款</a>
        <!--<a href="enterpriseLoan.html" class="ripple"><span class="icon f2"></span>企业贷款</a>
        <a href="transferLoan.html" class="ripple"><span class="icon f3"></span>转贷基金</a>-->
        <a href="my.html" class="ripple"  style="font-size: 14px;"><span class="icon f4"  style="width: 17px;height: 17px;"></span>我的</a>
    </footer>
    <script src="./scripts/jquery-1.10.1.min.js"></script>
    <script src="./scripts/idangerous.swiper.min.js"></script>
    <script>
        function inits(){
            var mySwiper = new Swiper('.swiper-container', {
                pagination: '.pagination',
                loop: true,
                grabCursor: true,
                paginationClickable: true,
                calculateHeight: true,
                autoplay : 3000,
            })
            $('.arrow-left').on('click', function (e) {
                e.preventDefault()
                mySwiper.swipePrev()
            })
            $('.arrow-right').on('click', function (e) {
                e.preventDefault()
                mySwiper.swipeNext()
            })
        }

        window.onload = function () {

            var useragent = navigator.userAgent;
            if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
                // 这里警告框会阻塞当前页面继续加载
                alert('已禁止本次访问：您必须使用微信内置浏览器访问本页面！');
                // 以下代码是用javascript强行关闭当前页面
                var opened = window.open('about:blank', '_self');
                opened.opener = null;
                opened.close();
            }



            function GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);

                return null;
            }

            console.log(GetQueryString("code"))
            //创建用户访问记录
            if(GetQueryString(name)){
                $.ajax({
                    type:'post',
                    url:"/loan/loanUserInfo/queryUserForOpenId",
                    data:{
                        openId:GetQueryString("code")
                    },
                    success:function(ss){
                        //console.log(ss.data.loanUserInfo,"asdasdasdasd")
                        //console.log($.isEmptyObject(ss.data.loanUserInfo))
                        if($.isEmptyObject(ss.data.loanUserInfo)){
                            $.ajax({
                                type:'post',
                                url:"/loan/loanUserInfo/createLoanUserInfo",
                                data:{
                                    openId:GetQueryString("code"),
                                    userWecat:"km",
                                    wecatName:"kingmon"
                                },
                                success : function(data){
                                    //console.log(data)
                                    setCookie("user",JSON.stringify(data.data.userId))
                                    // $.ajax({
                                    //     type:'post',
                                    //     url:"/loan/loanVisitInfo/createLoanVisitInfo",
                                    //     data:{
                                    //         userId:data.data.userId,
                                    //         //visitCategoryId:categoryId,
                                    //         //visitProductId:productId
                                    //     }
                                    // })
                                }
                            })
                        }else{
                            setCookie("user",JSON.stringify(ss.data.loanUserInfo.id))
                            // $.ajax({
                            //     type:'post',
                            //     url:"/loan/loanVisitInfo/createLoanVisitInfo",
                            //     data:{
                            //         userId:ss.data.loanUserInfo.id,
                            //         //visitCategoryId:categoryId,
                            //         //visitProductId:productId
                            //     }
                            // })
                        }

                    }
                })
            }

            $.ajax({
                url:"/loan/loanCategory/loadLoanCategoryDataSet",
                type:"post",
                success:function(ss){
                    var a = ''
                    for (var i = 0;i<ss.data.dataSet.rows.length;i++){
                        a += "<div onclick='loadLoanProduct("+ss.data.dataSet.rows[i].id+")'>" +
                            "<img src='images/"+ss.data.dataSet.rows[i].logo_path+".png' alt='"+ ss.data.dataSet.rows[i].category_name +"'>" +
                            "<p>"+ ss.data.dataSet.rows[i].category_name +"</p><" +
                            "/div>"
                    }
                    $(".type").append(a)
                    inits()
                }
            })
            loadLoanProduct(null);
        }


        function loadLoanProduct(val){

            $(".bank").find("img").remove()
            $(".bank").find("div").remove()
            $.ajax({
                url:"/loan/loanBankProduct/loadLoanBankProductDataSet",
                type:"post",
                data:{category_id:val},
                success:function(ss){
                    var b = ''
                    for (var i = 0; i < ss.data.dataSet.rows.length; i++) {
                        b += "<img src='images/"+ss.data.dataSet.rows[i].logo_path+".jpg'><div><p>" + ss.data.dataSet.rows[i].loan_type_name + "</p><p>综合费用：" + ss.data.dataSet.rows[i].colligate_cost + "</p><p>贷款期限：" +
                            ss.data.dataSet.rows[i].loan_term +
                            "</p></div><div class='detail'><a href='./apply.html?proid="+ss.data.dataSet.rows[i].id+"' style='color: red;text-decoration: none;'>贷款详情</a></div><div style='margin: 0px;margin-top: 10px;float: left;width: 100%;height: 1px;background: #dcdcdc;'></div>"
                    }
                    //setCookie("bank",JSON.stringify(ss.data.dataSet.rows))
                    $(".bank").append(b)
                    //console.log(ss.data.dataSet.rows)
                }
            })
        }

        function setCookie(name,value) {
            var Days = 30;
            var exp = new Date();
            exp.setTime(exp.getTime() + Days*24*60*60*1000);
            document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
        }

    </script>
</body>

</html>